=begin
author：SummerStarBreeze
information：I'm will made
=end

# Number
# Integer
num1 = 1;
num2 = 0b10;
num3 = 0o10;
num4 = 0x10;
num5 = 1_000_000;
# Float
f1 = 1.1;
f2 = 1.0e6;
f3 = 4E20;
f4 = 4e+20;
print "Num: ",[num1,num2,num3,num4,num5].join(",")+"\n";
print "Float: ",[f1,f2,f3,f4].join(",")+"\n";

# string
puts "waring encoding format 中文 English"
puts '外层加引号，\\会被转义'
puts "value of num1 is #{num1}"
puts %Q{value of num2 is #{num2}}
puts %q{value of num2 is #{num2}}
# array
arr1 = [ "mix", 10, 3.14, "This is a string", "last element", ]
print arr1,arr1[2],"\n";
# hash
hash = colors = {"red" => 0xf00,"blue" => 0x00f}
print colors["red"],"\n"
# range
(1..5).each do |n|
    print n, ' '
end
# Date & Time
time1 = Time.now;
time2 = Time.new;
print time1.to_s+"\n";
print time2;
print "year:" + time2.year.to_s + "\n"
print "month:" + time2.month.to_s + "\n"
print "day:" + time2.day.to_s + "\n"
print "wday:" + time2.wday.to_s + "\n"
print "yday:" + time2.yday.to_s + "\n"
print "hour:" + time2.hour.to_s + "\n"
print "min:" + time2.min.to_s + "\n"
print "second:"+time2.sec.to_s + "\n"
print "usec:" + time2.usec.to_s + "\n"
print "zone:" + time2.zone + "\n"
print "for time test to_a and get data of date "+time2.to_a.join(",")
##################### time.local utc ##############################
# July 8, 2008
puts Time.local(2008, 7, 8)  
# July 8, 2008, 09:10am，本地时间
puts Time.local(2008, 7, 8, 9, 10)   
# July 8, 2008, 09:10 UTC
puts Time.utc(2008, 7, 8, 9, 10)  
# July 8, 2008, 09:10:11 GMT （与 UTC 相同）
puts Time.gm(2008, 7, 8, 9, 10, 11)
##################### 夏令时和时区 ######################
puts time2.zone       # => "UTC"：返回时区
puts time2.utc_offset # => 0：UTC 是相对于 UTC 的 0 秒偏移
puts time2.zone       # => "PST"（或其他时区）
puts time2.isdst      # => false：如果 UTC 没有 DST（夏令时）
puts time2.utc?       # => true：如果在 UTC 时区
puts time2.localtime  # 转换为本地时区
puts time2.gmtime     # 转换回 UTC
puts time2.getlocal   # 返回本地区中的一个新的 Time 对象
puts time2.getutc     # 返回 UTC 中的一个新的 Time 对象
##################### 格式化时间和日期 ##################

puts time2.to_s
puts time2.ctime
puts time2.localtime
puts time2.strftime("%Y-%m-%d %H:%M:%S")